import Vue from 'vue'
import VueRouter from 'vue-router'
import Loyout from '@/loyout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Loyout,
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/Home'),
  },
  {
    // 房产经纪
    path: '/property',
    name: 'property',
    component: () => import('@/views/Property'),
  },
  {
    // 地产分类
    path: '/acre',
    name: 'acre',
    component: () => import('@/views/Acre'),
  },
  {
    // 关于我们
    path: '/about',
    name: 'about',
    component: () => import('@/views/About'),
  },
  {
    // 地产列表
    path: '/properties',
    name: 'properties',
    component: () => import('@/views/Properties'),
  },
  {
    // 地产详情
    path: '/details',
    name: 'details',
    component: () => import('@/views/Details'),
  },
  {
    // 列表页
    path: '/list',
    name: 'list',
    component: () => import('@/views/List'),
  }
]

const router = new VueRouter({
  routes
})
// 解决重复跳转到同一个路由报错问题，VueRouter是指路由对象
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
